home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / zsysvm.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  4.3 KB  |  161 lines

  1. /* Copyright (C) 1994, 1995, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: zsysvm.c,v 1.2 2000/09/19 19:00:55 lpd Exp $ */
  20. /* System VM and VM-specific operators */
  21. #include "ghost.h"
  22. #include "oper.h"
  23. #include "ialloc.h"
  24. #include "ivmspace.h"
  25. #include "store.h"        /* for make_bool */
  26.  
  27. /*
  28.  * These operators allow creation of objects in a specific VM --
  29.  * local, global, or system.  System VM, which is not a standard PostScript
  30.  * facility, is not subject to save and restore; objects in system VM
  31.  * may only refer to simple objects or to other (composite) objects
  32.  * in system VM.
  33.  */
  34.  
  35. /* Execute an operator with a specific VM selected as current VM. */
  36. private int
  37. specific_vm_op(i_ctx_t *i_ctx_p, op_proc_t opproc, uint space)
  38. {
  39.     uint save_space = icurrent_space;
  40.     int code;
  41.  
  42.     ialloc_set_space(idmemory, space);
  43.     code = opproc(i_ctx_p);
  44.     ialloc_set_space(idmemory, save_space);
  45.     return code;
  46. }
  47.  
  48. /* <int> .globalvmarray <array> */
  49. private int
  50. zglobalvmarray(i_ctx_t *i_ctx_p)
  51. {
  52.     return specific_vm_op(i_ctx_p, zarray, avm_global);
  53. }
  54.  
  55. /* <int> .globalvmdict <dict> */
  56. private int
  57. zglobalvmdict(i_ctx_t *i_ctx_p)
  58. {
  59.     return specific_vm_op(i_ctx_p, zdict, avm_global);
  60. }
  61.  
  62. /* <obj_0> ... <obj_n-1> <n> .globalvmpackedarray <packedarray> */
  63. private int
  64. zglobalvmpackedarray(i_ctx_t *i_ctx_p)
  65. {
  66.     return specific_vm_op(i_ctx_p, zpackedarray, avm_global);
  67. }
  68.  
  69. /* <int> .globalvmstring <string> */
  70. private int
  71. zglobalvmstring(i_ctx_t *i_ctx_p)
  72. {
  73.     return specific_vm_op(i_ctx_p, zstring, avm_global);
  74. }
  75.  
  76. /* <int> .localvmarray <array> */
  77. private int
  78. zlocalvmarray(i_ctx_t *i_ctx_p)
  79. {
  80.     return specific_vm_op(i_ctx_p, zarray, avm_local);
  81. }
  82.  
  83. /* <int> .localvmdict <dict> */
  84. private int
  85. zlocalvmdict(i_ctx_t *i_ctx_p)
  86. {
  87.     return specific_vm_op(i_ctx_p, zdict, avm_local);
  88. }
  89.  
  90. /* <obj_0> ... <obj_n-1> <n> .localvmpackedarray <packedarray> */
  91. private int
  92. zlocalvmpackedarray(i_ctx_t *i_ctx_p)
  93. {
  94.     return specific_vm_op(i_ctx_p, zpackedarray, avm_local);
  95. }
  96.  
  97. /* <int> .localvmstring <string> */
  98. private int
  99. zlocalvmstring(i_ctx_t *i_ctx_p)
  100. {
  101.     return specific_vm_op(i_ctx_p, zstring, avm_local);
  102. }
  103.  
  104. /* <int> .systemvmarray <array> */
  105. private int
  106. zsystemvmarray(i_ctx_t *i_ctx_p)
  107. {
  108.     return specific_vm_op(i_ctx_p, zarray, avm_system);
  109. }
  110.  
  111. /* <int> .systemvmdict <dict> */
  112. private int
  113. zsystemvmdict(i_ctx_t *i_ctx_p)
  114. {
  115.     return specific_vm_op(i_ctx_p, zdict, avm_system);
  116. }
  117.  
  118. /* <obj_0> ... <obj_n-1> <n> .systemvmpackedarray <packedarray> */
  119. private int
  120. zsystemvmpackedarray(i_ctx_t *i_ctx_p)
  121. {
  122.     return specific_vm_op(i_ctx_p, zpackedarray, avm_system);
  123. }
  124.  
  125. /* <int> .systemvmstring <string> */
  126. private int
  127. zsystemvmstring(i_ctx_t *i_ctx_p)
  128. {
  129.     return specific_vm_op(i_ctx_p, zstring, avm_system);
  130. }
  131.  
  132. /* <any> .systemvmcheck <bool> */
  133. private int
  134. zsystemvmcheck(i_ctx_t *i_ctx_p)
  135. {
  136.     os_ptr op = osp;
  137.  
  138.     make_bool(op, (r_space(op) == avm_system ? true : false));
  139.     return 0;
  140. }
  141.  
  142. /* ------ Initialization procedure ------ */
  143.  
  144. const op_def zsysvm_op_defs[] =
  145. {
  146.     {"1.globalvmarray", zglobalvmarray},
  147.     {"1.globalvmdict", zglobalvmdict},
  148.     {"1.globalvmpackedarray", zglobalvmpackedarray},
  149.     {"1.globalvmstring", zglobalvmstring},
  150.     {"1.localvmarray", zlocalvmarray},
  151.     {"1.localvmdict", zlocalvmdict},
  152.     {"1.localvmpackedarray", zlocalvmpackedarray},
  153.     {"1.localvmstring", zlocalvmstring},
  154.     {"1.systemvmarray", zsystemvmarray},
  155.     {"1.systemvmcheck", zsystemvmcheck},
  156.     {"1.systemvmdict", zsystemvmdict},
  157.     {"1.systemvmpackedarray", zsystemvmpackedarray},
  158.     {"1.systemvmstring", zsystemvmstring},
  159.     op_def_end(0)
  160. };
  161.